package com.nbsaas.boot.cms.rest.convert;

import com.nbsaas.boot.cms.data.entity.Article;
import com.nbsaas.boot.cms.api.domain.response.ArticleResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
    import java.util.HashMap;
    import java.util.Map;
/**
* 实体对象转化成响应对象
*/

public class ArticleResponseConvert  implements Converter<ArticleResponse,Article> {

    @Override
    public ArticleResponse convert(Article source) {
        ArticleResponse  result = new  ArticleResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getState()!=null){
                    Map<Integer,String> StateMap=new HashMap<>();
                        StateMap.put(1,"正常");
                        StateMap.put(2,"删除");
                    String label=  StateMap.get(source.getState());
                    result.setStateName(label);
                    }
                    result.setState(source.getState());
        return result;
    }

}

